/*
 * Copyright (C) 2014 Le Tuan Anh <tuananh.ke@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.dakside.duck.demo;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.event.EventListenerList;
import org.dakside.duck.appui.GroupModulePanel;

/**
 *
 * @author Le Tuan Anh <tuananh.ke@gmail.com>
 */
public class StartPage extends JPanel {

    protected EventListenerList activationListener = new EventListenerList();

    public void addActiveStateChangedListener(ActionListener l) {
        activationListener.add(ActionListener.class, l);
    }

    public void removeActiveStateChangedListener(ActionListener l) {
        activationListener.remove(ActionListener.class, l);
    }

    private void fireActiveStateChanged(ActionEvent e) {
        if (e == null) {
            e = new ActionEvent(this, 0, "");
        }
        Object[] listeners = activationListener.getListenerList();
        for (int i = listeners.length - 2; i >= 0; i -= 2) {
            if (listeners[i] == ActionListener.class) {
                ((ActionListener) listeners[i + 1]).actionPerformed(e);
            }
        }
    }

    public boolean isActivated() {
        return this.isEnabled();
    }

    /**
     * Creates new form StartPage
     */
    public StartPage() {
        initComponents();

        try {
            this.groupModulePanel.load();
        } catch (Exception ex) {
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        groupModulePanel = new org.dakside.duck.appui.GroupModulePanel();

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(groupModulePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(groupModulePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.dakside.duck.appui.GroupModulePanel groupModulePanel;
    // End of variables declaration//GEN-END:variables

    public GroupModulePanel getGroupModulePanel() {
        return groupModulePanel;
    }

}
